﻿package com.dg.gaming.api.common.msg
{
	import nanoxml.*;

	/**
	 * <p>Title: </p>
	 *
	 * <p>Description: </p>
	 *
	 * <p>Copyright: Copyright (c) 2009</p>
	 *
	 * <p>Company: </p>
	 *
	 * @author not attributable
	 * @version 1.0
	 */
	public class MsgNoMove extends MsgTableMessage
	{
		public static const XML_ATT_NOMOVE:String="nomove";
		private static const XML_ATT_DELEY:String="deley";
		private static const XML_ATT_LOSE:String="lose";
		private var deley:int;
		private var lose:Boolean;

		public function MsgNoMove(deley:int=1, lose:Boolean=false, message:XMLElement=null)
		{

			this.deley=deley;
			this.lose=lose;
			if (message != null)
				super(message);

			if (message == null)
				return;
			deley=message.getIntAttribute(XML_ATT_DELEY);
			lose=message.getIntAttribute(XML_ATT_DELEY) == 1;
		}

		/**
		 * This method flattens an ITransmittable object into a XMLElement which
		 * can be transmitted.
		 *
		 * @return XML version of the state of an object which can be
		 *   constructed again.
		 * @todo Implement this com.dg.gaming.api.common.msg.ITransmittable
		 *   method
		 */
		public override function flatten():XMLElement
		{
			var ele:XMLElement=super.flattenWithName(XML_ATT_NOMOVE);
			ele.setIntAttribute(XML_ATT_DELEY, deley);
			ele.setIntAttribute(XML_ATT_LOSE, lose ? 1 : 2);
			return ele;
		}

		public function getDeley():int
		{
			return deley;
		}

		public function isLose():Boolean
		{
			return lose;
		}
	}
}